<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.util.List"%>    
<%@ page import="minipost.post.model.Post"%>
<%@ page import="minipost.post.PostBean"%>

<%
	request.setCharacterEncoding("UTF-8");
	PostBean postBean = new PostBean();
%>


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>首页</title>
    <link rel="stylesheet" type="text/css" href="css/style.css"/>
    <script type="text/javascript" src="js/jquery.js"></script>
    <script type="text/javascript" src="js/public.js"></script>
    <script type="text/javascript" src="js/index.js"></script>
</head>
<body>
    <div id="head">
    </div>
    <div class="clean"></div>
    <div id="nav">
        <div class="content">
            <div class="left">
                <ul>
                    <li class="active"><a href="index.jsp">首页</a></li>
                    <li><a href="category.jsp?type=home">国内</a></li>
                    <li><a href="category.jsp?type=abroad">国外</a></li>
                    <li><a href="category.jsp?type=society">社会</a></li>
                    <li><a href="category.jsp?type=tech">科技</a></li>
                </ul>
            </div>
            <div class="right" id="current_time"></div>
        </div>
    </div>
    <div class="clean"></div>
    <div id="index">
        <div class="pic">
            <div class="pic-1">
                <ul>
                    <li class="show"><img src="images/1.jpeg" width="550" height="340"></li>
                    <li><img src="images/2.png" width="550" height="340"></li>
                    <li><img src="images/3.jpg" width="550" height="340"></li>
                    <li><img src="images/4.jpg" width="550" height="340"></li>
                    <li><img src="images/5.jpg" width="550" height="340"></li>
                </ul>
            </div>
            <div class="pic-2">
                <ul>
                    <li class="show"><a href="javascript:void(0);">1</a></li>
                    <li><a href="javascript:void(0);">2</a></li>
                    <li><a href="javascript:void(0);">3</a></li>
                    <li><a href="javascript:void(0);">4</a></li>
                    <li><a href="javascript:void(0);">5</a></li>
                </ul>
            </div>
            <div class="pic-3">
                <p class="show">Facebook被曝出技术故障影响波及全球</p>
                <p>Galaxy S5相机遇故障</p>
                <p>The design of the entrance for a Perth Concert Hall.</p>
                <p>《舌尖上的中国》中让人垂涎的美食。</p>
                <p>5月1日，在匈牙利首都布达佩斯，匈牙利飞行员韦赖什·佐尔坦驾驶飞机在多瑙河上空进行飞行表演。</p>
            </div>
        </div>
        <div class="tzgg">
            <div class="category">
                <a href="category.jsp?type=tech" class="name">科技</a>
                <a href="category.jsp?type=tech" class="more">更多</a>
            </div>
            <div class="list">
                <ul>
                <%
                	List<Post> technology = postBean.getPostByType("科技");
                	if (technology == null) {
                %>
                		<li><span class="title">没有相关新闻</span></li>
                <%
                	} else {
                		int length = technology.size();
                		for (int i = 0; i < length; ++i) {
                			Post currentPost = technology.get(i);
               %>
               		<li><span class="title"><a href="single.jsp?id=<%= currentPost.getId()%>"><%= currentPost.getPostTitle()%></a></span><span class="time"><%= currentPost.getPostDateAsString()%></span></li>
               <% 
               			}
                	} %>                    
                </ul>
            </div>
        </div>
        <div class="clean">
        </div>
        <div class="mid-pic">
        </div>
        <div class="col-3">
            <div class="category">
                <a href="category.jsp?type=home" class="name">国内</a>
                <a href="category.jsp?type=home" class="more">更多</a>
            </div>
            <div class="list">
                <ul>
				<%
                	List<Post> home = postBean.getPostByType("国内");
                	if (home == null) {
                %>
                		<li><span class="title">没有相关新闻</span></li>
                <%
                	} else {
                		int length = home.size();
                		for (int i = 0; i < length; ++i) {
                			Post currentPost = home.get(i);
               %>
               		<li><span class="title"><a href="single.jsp?id=<%= currentPost.getId()%>"><%= currentPost.getPostTitle()%></a></span><span class="time"><%= currentPost.getPostDateAsString()%></span></li>
               <% 
               			}
                	} %>
				</ul>
            </div>
        </div>
        <div class="col-3 mid">
            <div class="category">
                <a href="category.jsp?type=abroad" class="name">国外</a>
                <a href="category.jsp?type=abroad" class="more">更多</a>
            </div>
            <div class="list">
                <ul>
 				<%
                	List<Post> abroad = postBean.getPostByType("国外");
                	if (abroad == null) {
                %>
                		<li><span class="title">没有相关新闻</span></li>
                <%
                	} else {
                		int length = abroad.size();
                		for (int i = 0; i < length; ++i) {
                			Post currentPost = abroad.get(i);
               %>
               		<li><span class="title"><a href="single.jsp?id=<%= currentPost.getId()%>"><%= currentPost.getPostTitle()%></a></span><span class="time"><%= currentPost.getPostDateAsString()%></span></li>
               <% 
               			}
                	} %>
				</ul>
            </div>
        </div>
        <div class="col-3">
            <div class="category">
                <a href="category.jsp?type=society" class="name">社会</a>
                <a href="category.jsp?type=society" class="more">更多</a>
            </div>
            <div class="list">
                <ul>
 				<%
                	List<Post> society = postBean.getPostByType("社会");
                	if (society == null) {
                %>
                		<li><span class="title">没有相关新闻</span></li>
                <%
                	} else {
                		int length = society.size();
                		for (int i = 0; i < length; ++i) {
                			Post currentPost = society.get(i);
               %>
               		<li><span class="title"><a href="single.jsp?id=<%= currentPost.getId()%>"><%= currentPost.getPostTitle()%></a></span><span class="time"><%= currentPost.getPostDateAsString()%></span></li>
               <% 
               			}
                	} %>
				</ul>
            </div>
        </div>
    </div>
    <div class="clean"></div>
    <div id="foot">
        Copyright&copy;&nbsp;合肥工业大学网站设计基础
    </div>
</body>
</html>